package com.mvcplus.system.controller;

import com.mvcplus.common.controller.BaseController;
import com.mvcplus.system.model.DicDictionaryType;
import com.mvcplus.system.service.IDicDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by BINGO on 2016/10/28.
 * 数据字典类型
 */
@Controller
@Scope(value = "prototype")
@RequestMapping("/dicType")
public class DictionaryTypeController extends BaseController{

    @Autowired
    private IDicDictionaryTypeService dicTypeService;

    @ResponseBody
    @RequestMapping("/add")
    public Object add(DicDictionaryType dictionaryType){
        return dicTypeService.insertSelective(dictionaryType) ? renderSuccess("添加成功") : renderError("添加失败");
    }

    @ResponseBody
    @RequestMapping("/delete")
    public Object delete(@RequestParam(required = false, value = "ids[]")List<Long> ids) {
        return dicTypeService.deleteBatchIds(ids) ? renderSuccess("删除成功") : renderError("删除失败");
    }

    @ResponseBody
    @RequestMapping("/update")
    public Object update(DicDictionaryType dictionaryType) {
        return dicTypeService.updateSelectiveById(dictionaryType)? renderSuccess("修改成功") : renderError("修改失败");
    }


}
